package order

import (
	"context"
	// "fmt"

	"mall/common/utils/pointy"
	"mall/service/backend/api/internal/svc"
	"mall/service/backend/api/internal/types"
	"mall/service/backend/common/i18n"

	// "github.com/sirupsen/logrus"
	"github.com/zeromicro/go-zero/core/logx"
)

type GetPredefinedListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetPredefinedListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPredefinedListLogic {
	return &GetPredefinedListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetPredefinedListLogic) GetPredefinedList() (*types.OrderPredefinedListResp, error) {
	formDefault := []*types.MetaInfo{
		{
			Key:   pointy.GetPointer("status"),
			Value: pointy.GetPointer("0"),
		},
	}

	statusList := []*types.MetaInfo{
		{
			Key:   pointy.GetPointer("pending"),
			Name:  pointy.GetPointer("待付款"),
			Slug:  pointy.GetPointer("pending"),
			Value: pointy.GetPointer("11"),
		},
		{
			Key:   pointy.GetPointer("userCancelled"),
			Name:  pointy.GetPointer("取消付款"),
			Slug:  pointy.GetPointer("cancelled"),
			Value: pointy.GetPointer("12"),
		},
		{
			Key:   pointy.GetPointer("autoCancelled"),
			Name:  pointy.GetPointer("取消付款"),
			Slug:  pointy.GetPointer("cancelled"),
			Value: pointy.GetPointer("13"),
		},
		{
			Key:   pointy.GetPointer("adminCancelled"),
			Name:  pointy.GetPointer("取消付款"),
			Slug:  pointy.GetPointer("cancelled"),
			Value: pointy.GetPointer("14"),
		},
		{
			Key:   pointy.GetPointer("paid"),
			Name:  pointy.GetPointer("已付款、待发货"),
			Slug:  pointy.GetPointer("paid"),
			Value: pointy.GetPointer("21"),
		},
		{
			Key:   pointy.GetPointer("shipping"),
			Name:  pointy.GetPointer("备货中、正在出库"),
			Slug:  pointy.GetPointer("shipping"),
			Value: pointy.GetPointer("31"),
		},
		{
			Key:   pointy.GetPointer("shipped"),
			Name:  pointy.GetPointer("已发货、待收货"),
			Slug:  pointy.GetPointer("shipped"),
			Value: pointy.GetPointer("32"),
		},
		{
			Key:   pointy.GetPointer("delivering"),
			Name:  pointy.GetPointer("配送中"),
			Slug:  pointy.GetPointer("delivering"),
			Value: pointy.GetPointer("41"),
		},
		{
			Key:   pointy.GetPointer("delivered"),
			Name:  pointy.GetPointer("已配送"),
			Slug:  pointy.GetPointer("delivered"),
			Value: pointy.GetPointer("42"),
		},
		{
			Key:   pointy.GetPointer("received"),
			Name:  pointy.GetPointer("确认收货"),
			Slug:  pointy.GetPointer("received"),
			Value: pointy.GetPointer("51"),
		},
		{
			Key:   pointy.GetPointer("autoReceived"),
			Name:  pointy.GetPointer("确认收货"),
			Slug:  pointy.GetPointer("received"),
			Value: pointy.GetPointer("52"),
		},
		{
			Key:   pointy.GetPointer("reviewed"),
			Name:  pointy.GetPointer("已评价"),
			Slug:  pointy.GetPointer("reviewed"),
			Value: pointy.GetPointer("61"),
		},
		{
			Key:   pointy.GetPointer("autoReviewed"),
			Name:  pointy.GetPointer("已评价"),
			Slug:  pointy.GetPointer("reviewed"),
			Value: pointy.GetPointer("62"),
		},
		{
			Key:   pointy.GetPointer("fulfilled"),
			Name:  pointy.GetPointer("已完成"),
			Slug:  pointy.GetPointer("fulfilled"),
			Value: pointy.GetPointer("71"),
		},
		{
			Key:   pointy.GetPointer("closed"),
			Name:  pointy.GetPointer("已关闭"),
			Slug:  pointy.GetPointer("closed"),
			Value: pointy.GetPointer("79"),
		},
		{
			Key:   pointy.GetPointer("refund"),
			Name:  pointy.GetPointer("退款申请"),
			Slug:  pointy.GetPointer("refund"),
			Value: pointy.GetPointer("81"),
		},
		{
			Key:   pointy.GetPointer("refunding"),
			Name:  pointy.GetPointer("退款中"),
			Slug:  pointy.GetPointer("refunding"),
			Value: pointy.GetPointer("82"),
		},
		{
			Key:   pointy.GetPointer("refunded"),
			Name:  pointy.GetPointer("已退款"),
			Slug:  pointy.GetPointer("refunded"),
			Value: pointy.GetPointer("83"),
		},
		{
			Key:   pointy.GetPointer("adminRefunding"),
			Name:  pointy.GetPointer("退款中"),
			Slug:  pointy.GetPointer("refunding"),
			Value: pointy.GetPointer("84"),
		},
		{
			Key:   pointy.GetPointer("adminRefunded"),
			Name:  pointy.GetPointer("已退款"),
			Slug:  pointy.GetPointer("refunded"),
			Value: pointy.GetPointer("85"),
		},
		{
			Key:   pointy.GetPointer("return"),
			Name:  pointy.GetPointer("退货申请"),
			Slug:  pointy.GetPointer("return"),
			Value: pointy.GetPointer("91"),
		},
		{
			Key:   pointy.GetPointer("returning"),
			Name:  pointy.GetPointer("退货中"),
			Slug:  pointy.GetPointer("returning"),
			Value: pointy.GetPointer("92"),
		},
		{
			Key:   pointy.GetPointer("returned"),
			Name:  pointy.GetPointer("已退货"),
			Slug:  pointy.GetPointer("returned"),
			Value: pointy.GetPointer("93"),
		},
		{
			Key:   pointy.GetPointer("deleted"),
			Name:  pointy.GetPointer("回收站"),
			Slug:  pointy.GetPointer("deleted"),
			Value: pointy.GetPointer("4"),
		},
	}

	orderTypeList := []*types.MetaInfo{
		{
			Key:   pointy.GetPointer("common"),
			Name:  pointy.GetPointer("普通商品"),
			Slug:  pointy.GetPointer("common"),
			Value: pointy.GetPointer("21"),
		},
		{
			Key:   pointy.GetPointer("tester"),
			Name:  pointy.GetPointer("试香"),
			Slug:  pointy.GetPointer("tester"),
			Value: pointy.GetPointer("22"),
		},
		{
			Key:   pointy.GetPointer("seckill"),
			Name:  pointy.GetPointer("秒杀"),
			Slug:  pointy.GetPointer("seckill"),
			Value: pointy.GetPointer("11"),
		},
		{
			Key:   pointy.GetPointer("virtual"),
			Name:  pointy.GetPointer("虚拟物品"),
			Slug:  pointy.GetPointer("virtual"),
			Value: pointy.GetPointer("1"),
		},
	}

	metaKeyList := []*types.MetaInfo{
		{
			Key:  pointy.GetPointer("title"),
			Name: pointy.GetPointer("标题"),
			Slug: pointy.GetPointer("title"),
		},
		{
			Key:  pointy.GetPointer("keywords"),
			Name: pointy.GetPointer("关键词"),
			Slug: pointy.GetPointer("keywords"),
		},
		{
			Key:  pointy.GetPointer("description"),
			Name: pointy.GetPointer("描述"),
			Slug: pointy.GetPointer("description"),
		},
	}

	return &types.OrderPredefinedListResp{
		BaseDataInfo: types.BaseDataInfo{
			Success: true,
			Msg:     l.svcCtx.Trans.Trans(l.ctx, i18n.Success),
		},
		Data: types.OrderPredefinedListInfo{
			FormDefault:   formDefault,
			StatusList:    statusList,
			MetaKeyList:   metaKeyList,
			OrderTypeList: orderTypeList,
		},
	}, nil
}
